package com.beteng.su.betengsu.adapter;

import android.content.Context;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.beteng.su.betengsu.R;
import com.beteng.su.betengsu.bean.OrderBean;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.droidlover.xdroid.base.SimpleRecAdapter;

/**
 * Created by yy on 2017/8/4.
 */

public class OrderSearchAdapter extends SimpleRecAdapter<OrderBean, OrderSearchAdapter.Holder> {


    public OrderSearchAdapter(Context context) {
        super(context);
    }

    @Override
    public void onBindViewHolder(final Holder holder, final int position) {
        final OrderBean orderBean = getDataSource().get(position);
        holder.mSearchItemOrderNoQudao.setText(orderBean.getSupplierWaybillNO() + "");
        holder.mSearchItemOrderNoBeteng.setText(String.format("%d", orderBean.getWaybillID()));
        holder.mSearchItemLocation.setText(String.format("%s", orderBean.getToPurposeName()));
        holder.mSearchItemCarno.setText(orderBean.getPlate() + "");
        holder.mSearchItemRecname.setText(orderBean.getReceivePerson() + "");

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                getRecItemClick().onItemClick(position,orderBean,position,holder);
            }
        });

        holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                getRecItemClick().onItemLongClick(position,orderBean,position,holder);
                return false;
            }
        });




    }

    @Override
    public Holder newViewHolder(View itemView) {

        return new Holder(itemView);
    }

    @Override
    public int getLayoutId() {
        return R.layout.areusleep_list_item;
    }




    public class Holder extends RecyclerView.ViewHolder {
        @BindView(R.id.search_item_order_no_qudao)
        TextView mSearchItemOrderNoQudao;
        @BindView(R.id.search_item_order_no_beteng)
        TextView mSearchItemOrderNoBeteng;
        @BindView(R.id.search_item_location)
        TextView mSearchItemLocation;
        @BindView(R.id.search_item_carno)
        TextView mSearchItemCarno;
        @BindView(R.id.search_item_recname)
        TextView mSearchItemRecname;
        @BindView(R.id.search_item_layout)
        CardView mSearchItemLayout;

        Holder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
